package com.road7.mina.customCodec;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;

import com.road7.mina.simpledemo.PBMessage;

/**
 * @Description :
 * @FileName: RouteHandler.java
 * @Author :WeiHui.Zhang
 * @Data : 2015年11月20日 上午10:35:53
 * @Version:V1.00
 */
public abstract class RouteHandler extends IoHandlerAdapter {

	protected String handName;

	public RouteHandler(String handName) {
		this.handName = handName;
	}

	@Override
	public void messageReceived(IoSession session, Object message) throws Exception {
		PBMessage packet = (PBMessage) message;
		
		short code = packet.getCode();
		
		System.out.println(code);
	}

	@Override
	public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
		session.close(true);
	}
}
